<template>
  <div id="shuiLiang">
    <div class="wrap">
      <div
        class="item "
        v-for="(item, index) in list"
        :key="'item' + index + item.num"
        :style="{
          fontSize: index < 2 ? '0.4rem' : '0.3rem',
          height: index < 2 ? '1.4rem' : '1rem',
          width: index < 2 ? '45%' : '',
          margin: index < 2 ? '0 2.5%' : '',
        }"
      >
        <div :style="{ paddingTop: index < 2 ? '0.15rem' : '' }">
          {{ item.name }}
        </div>
        <div>{{ item.num }}</div>
      </div>
      <div class="item2 ">
        <div class="item2-item">
          <div>月任务通过率</div>
          <shuiLiangChart
            :id="rate[0].id"
            :tips="rate[0].tips"
            :colorObj="rate[0].colorData"
          />
        </div>
        <div class="item2-item">
          <div>月任务达标率</div>
          <shuiLiangChart
            :id="rate[1].id"
            :tips="rate[1].tips"
            :colorObj="rate[1].colorData"
          />
        </div>
      </div>
      <div class="item3 ">
        <div v-for="(item, index) in list2" :key="index">
          {{ item.name }}：{{ Number(item.value || 0).toFixed(3) }}Mpa
        </div>
        <!-- <dv-water-level-pond :config="water" style="height: 1.5rem;width: 3rem;" /> -->
      </div>
    </div>
  </div>
</template>

<script>
import shuiLiangChart from "@/components/echart/shuiLiangChart";
export default {
  components: {
    shuiLiangChart,
  },
  created() {
    setTimeout(() => {
      this.changData();
      this.timer = setInterval(this.changData, 60000);
    }, 200);
  },
  methods: {
    async changData() {
      let result = await this.$http.get("api/bi/getBiCurrentTotalNum.do");
      if (result && result.status === 200) {
        var data = result.data;
        let list = [];
        this.list.forEach((item, index) => {
          if (data[item.k]) {
            item.num = Number(data[item.k]).toFixed(1);
          }
          list.push(item);
        });
        this.list = list;
        this.water.data[1] = Number(
          (Number(data.SSGS) / Number(data.SSQS)) * 100
        ).toFixed(2);
        this.water = JSON.parse(JSON.stringify(this.water));
      }
      let result2 = await this.$http.get("api/bi/selectLineYL.do");
      if (result2 && result2.status === 200) {
        this.list2 = result2.data;
      }
    },
  },
  data() {
    return {
      list: [
        { k: "NDQS", name: "年度累计取水量(m³)", num: 0 },
        { k: "NDGS", name: "年度累计供水量(m³)", num: 0 },
        { k: "SSQS", name: "实时取水量(m³/h)", num: 0 },
        { k: "BRQS", name: "本日累计取水(m³)", num: 0 },
        { k: "BYQS", name: "本月累计取水(m³)", num: 0 },
        { k: "SSGS", name: "实时供水量(m³/h)", num: 0 },
        { k: "BRGS", name: "本日累计供水(m³)", num: 0 },
        { k: "BYGS", name: "本月累计供水(m³)", num: 0 },
      ],
      list2: [],

      //取水供水比例
      water: {
        data: [0, 0],
        shape: "roundRect",
        formatter: "{value}%",
        waveNum: 3,
      },
      //月迅检完成和月数障完成率的组件复用数据
      rate: [
        {
          id: "centerRate1",
          tips: 97.9,
          colorData: {
            textStyle: "#3fc0fb",
            series: {
              color: ["#00bcd44a", "transparent"],
              dataColor: {
                normal: "#03a9f4",
                shadowColor: "#97e2f5",
              },
            },
          },
        },
        {
          id: "centerRate2",
          tips: 95,
          colorData: {
            textStyle: "#67e0e3",
            series: {
              color: ["#faf3a378", "transparent"],
              dataColor: {
                normal: "#ff9800",
                shadowColor: "#fcebad",
              },
            },
          },
        },
      ],
      timer: "",
    };
  },
};
</script>

<style lang="scss" scoped>
#shuiLiang {
  margin: 0.2rem 0.2rem 0 0.2rem;
  height: 5.3625rem;
  .wrap {
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    .item {
      height: 1rem;
      /*background-color: rgba(19, 25, 47, 0.6);*/
      width: 32.7%;
      color: #15cbb7;
      font-weight: bold;
      font-size: 0.3rem;
      text-align: center;
      div:first-child {
        color: white;
        font-size: 0.22rem;
        line-height: 0.62rem;
      }
    }
    .item2 {
      /*background-color: rgba(19, 25, 47, 0.6);*/
      display: flex;
      width: 48%;
      margin: 0 1%;
      justify-content: space-between;
      text-align: center;
      padding-top: 0.2rem;
      .item2-item {
        div:first-child {
          font-size: 0.15rem;
          color: white;
          margin-bottom: 0.1rem;
        }
      }
    }
    .item3 {
      /*background-color: rgba(19, 25, 47, 0.6);*/
      width: 48%;
      margin: 0 1%;
      // display: flex;
      justify-content: center;
      position: relative;
      padding: 0.2rem;
      div {
        font-size: 0.25rem;
        color: white;
        text-align: center;
        margin-top: 0.2rem;
      }
    }
  }
}
</style>
